<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <style>
        [v-cloak]{
            display: none;
        }
    </style>
</head>
<body>
<div id="app" v-cloak>
    <select multiple size="3" v-model="fruits">
        <option :value="item.value"
                v-for="item in allFruits"
                :key="item.value">
            {{item.text}}
        </option>
    </select>
    <h2>多选：{{fruits}}</h2>
    <hr>
    <div class="hobbies">
        <template v-for="item in allHobbies"
        :key="item.value">
            <label :for="item.value">
                <input :id="item.value" type="checkbox" v-model="hobbies" :value="item.value">{{item.text}}
            </label>
        </template>
    </div>
    <h2>爱好：{{hobbies}}</h2>
</div>
<script src="https://unpkg.com/vue@3"></script>
<script>
    const app=Vue.createApp({
        data(){
            return{
                // 水果
                allFruits: [
                    { value: "apple", text: "苹果" },
                    { value: "orange", text: "橘子" },
                    { value: "banana", text: "香蕉" },
                ],
                fruits: [],

                // 爱好
                allHobbies: [
                    { value: "sing", text: "唱" },
                    { value: "jump", text: "跳" },
                    { value: "rap", text: "rap" },
                    { value: "basketball", text: "篮球" }
                ],
                hobbies: []
            }
        },
        methods:{

        }
    })
    app.mount("#app")
</script>
</body>
</html>